<!--
 * @Author: JerryK
 * @Date: 2021-10-14 16:39:02
 * @LastEditors: Jerryk jerry@icewhale.org
 * @LastEditTime: 2022-06-21 12:36:07
 * @Description: 
 * @FilePath: \CasaOS-UI\src\components\fileList\ListItem.vue
-->
<template>
  <li class="ficon is-flex is-align-items-center" :class="[{active:state}]" @click="activeSelf" @dblclick="expandDir">
    <div class="cover">
      <div :class="item | coverType">
        <img alt="folder" :src="getIconFile(item)" :class="item | iconType" />
      </div>
    </div>
    <div class="one-line">
      {{name}}
    </div>

  </li>
</template>

<script>
import { mixin } from '@/mixins/mixin';
export default {
  name: "list-item",
  mixins: [mixin],
  data() {
    return {
      isActive: this.state
    }
  },
  props: {
    item: {},
    name: String,
    path: String,
    state: Boolean,
    IsDir: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    icon() {
      if (this.IsDir) {
        return "folder"
      } else {
        return "file"
      }
    }
  },
  methods: {
    activeSelf() {
      this.isActive = true;
      this.$emit("active", this.path)
    },
    expandDir() {
      if (this.IsDir) {
        this.$emit("expand", this.path)
      }
    }
  },

}
</script>

<style lang="scss" scoped>
.ficon {
  padding: 0.5rem 0.5rem 0.5rem 0.8rem;
  -webkit-touch-callout: none;
  user-select: none;
  font-size: 0.875rem;

  .cover {
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
  }
}
</style>